<template>
  <div class="zheli-construct-pro-info">
    <el-row :gutter="20">
      <el-col :span="12"
              v-if="objRowRequest.is_indust_project =='1'">
        <el-form-item label="建设性质"
                      prop="construct_nature">
          <el-select v-model="objRowRequest.construct_nature"
                     class="sel-style"
                     placeholder="请选择建设性质">
            <el-option v-for="item in buildingPropertyCode"
                       :key="item.code_id"
                       :label="item.name"
                       :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="项目类型"
                      prop="project_type">
          <el-select v-model="objRowRequest.project_type"
                     class="sel-style"
                     placeholder="请选择项目类型">
            <el-option v-for="item in projectTypeCode"
                       :key="item.code_id"
                       :label="item.name"
                       :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="工程用途"
                      prop="project_usage">
          <el-select v-model="objRowRequest.project_usage"
                     class="sel-style"
                     placeholder="请选择工程用途">
            <el-option v-for="item in projectUseageCode"
                       :key="item.code_id"
                       :label="item.name"
                       :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="项目状态"
                      prop="project_status">
          <el-select v-model="objRowRequest.project_status"
                     class="sel-style"
                     placeholder="请选择项目状态">
            <el-option v-for="item in projectStateCode"
                       :key="item.code_id"
                       :label="item.name"
                       :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="项目投资性质"
                      prop="invest_nature">
          <el-select v-model="objRowRequest.invest_nature"
                     class="sel-style"
                     placeholder="请选择项目投资性质">
            <el-option v-for="item in investPropertyCode"
                       :key="item.code_id"
                       :label="item.name"
                       :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="合同价格（万元）"
                      prop="contract_price">
          <el-input-number v-model="objRowRequest.contract_price"
                           placeholder="请输入合同价格"></el-input-number>
        </el-form-item>
        <el-form-item label="视频安装状态"
                      prop="video_install_status">
          <el-select v-model="objRowRequest.video_install_status"
                     class="sel-style"
                     placeholder="请选择视频安装状态">
            <el-option v-for="item in videoInstallCode"
                       :key="item.code_id"
                       :label="item.name"
                       :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="建设单位名称"
                      prop="build_company">
          <el-input v-model="objRowRequest.build_company"
                    placeholder="请输入建设单位名称"></el-input>
        </el-form-item>
        <el-form-item label="建设单位负责人"
                      prop="design_leader_name">
          <el-input v-model="objRowRequest.design_leader_name"
                    placeholder="请输入建设单位负责人"></el-input>
        </el-form-item>
        <el-form-item label="建设单位社会统一信用代码"
                      prop="build_credit_code">
          <el-input v-model="objRowRequest.build_credit_code"
                    placeholder="请输入建设单位社会统一信用代码"></el-input>
        </el-form-item>
        <el-form-item label="是否集中建设"
                      prop="is_converge">
          <el-radio-group :disabled="status==='detail'"
                          v-model="objRowRequest.is_converge">
            <el-radio label="1">是</el-radio>
            <el-radio label="0">否</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="是否重点项目"
                      prop="is_important">
          <el-radio-group :disabled="status==='detail'"
                          v-model="objRowRequest.is_important">
            <el-radio label="1">是</el-radio>
            <el-radio label="0">否</el-radio>
          </el-radio-group>
        </el-form-item>
      </el-col>
      <el-col :span="12"
              v-if="objRowRequest.is_indust_project === '1'"
              class="right-box">
        <el-form-item label="合同开工日期"
                      class="start-date-style"
                      prop="contract_start_date">
          <el-date-picker v-model="objRowRequest.contract_start_date"
                          :disabled="status==='detail'"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择合同开工日期"></el-date-picker>
        </el-form-item>
        <el-form-item label="合同竣工日期"
                      prop="contract_end_date">
          <el-date-picker v-model="objRowRequest.contract_end_date"
                          value-format="yyyy-MM-dd"
                          :disabled="status==='detail'"
                          placeholder="请选择合同竣工日期"></el-date-picker>
        </el-form-item>
        <el-form-item label="合同工期"
                      prop="contract_days">
          <el-input v-model="objRowRequest.contract_days"
                    :disabled="status==='detail'"
                    placeholder="请选择合同工期"> <template slot="append">天</template></el-input>
        </el-form-item>
        <el-form-item label="总用地面积">
          <el-input v-model="objRowRequest.land_area"
                    :disabled="status==='detail'"
                    placeholder="请输入总用地面积">
            <template slot="append">㎡</template>
          </el-input>
        </el-form-item>
        <el-form-item label="建设规模面积"
                      prop="land_area">
          <el-input v-model="objRowRequest.total_build_area"
                    :disabled="status==='detail'"
                    placeholder="请输入建设规模面积">
            <template slot="append">㎡</template>
          </el-input>
        </el-form-item>
        <el-form-item label="计划开工日期"
                      class="start-date-style"
                      prop="plan_start_date">
          <el-date-picker v-model="objRowRequest.plan_start_date"
                          :disabled="status==='detail'"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择计划开工日期"></el-date-picker>
        </el-form-item>
        <el-form-item label="计划竣工日期"
                      prop="plan_end_date">
          <el-date-picker v-model="objRowRequest.plan_end_date"
                          value-format="yyyy-MM-dd"
                          :disabled="status==='detail'"
                          placeholder="请选择计划竣工日期"></el-date-picker>
        </el-form-item>
        <el-form-item label="总投资"
                      prop="total_invest">
          <el-input v-model="objRowRequest.total_invest"
                    :disabled="status==='detail'"
                    placeholder="请输入总投资">
            <template slot="append">万元</template>
          </el-input>
        </el-form-item>
        <el-form-item label="总造价"
                      prop="totall_cost">
          <el-input v-model="objRowRequest.totall_cost"
                    :disabled="status==='detail'"
                    placeholder="请输入总造价">
            <template slot="append">万元</template>
          </el-input>
        </el-form-item>
        <el-form-item label="审批机构级别"
                      prop="approval_auth_level">
          <el-select v-model="objRowRequest.approval_auth_level"
                     class="sel-style"
                     placeholder="请选择审批机构级别">
            <el-option v-for="item in approvalCode"
                       :key="item.code_id"
                       :label="item.name"
                       :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
      </el-col>
    </el-row>
  </div>
</template>
<script>
import { operaProjectMixin } from '@/mixins/operaProjectMixins';
import { standardCodeApi } from '@/services/StandardCode';
export default {
  mixins: [operaProjectMixin],
  data () {
    return {
    }
  },
  methods: {
    // 初始化标准码
    async initCode (code, codeData, codeMap, codeLocal) {
      let local = window.localStorage.getItem(codeLocal)

      if (local) {
        this[codeData] = JSON.parse(local)
        this[codeData].map((item) => {
          this[codeMap][item.value] = item
        })
      } else {
        await this.getStandardCode(code, codeData, codeMap, codeLocal)
      }
    },
    // 获取标准码
    getStandardCode (code, codeData, codeMap, codeLocal) {

      return standardCodeApi.getStandardCodeData({
        data: {
          code_type: code
        }
      }).then(res => {
        if (res.code === 0 && res.data.list) {
          this[codeData] = res.data.list;
          this[codeData].map((item) => {
            this[codeMap][item.value] = item
          })
          window.localStorage.setItem(codeLocal, JSON.stringify(res.data.list));
        }
      },
        err => {
          console.log(err);
        }
      );
    }
  },
  watch: {
  },
  created () {
    // 视频安装状态标准码
    this.initCode('video_install', 'videoInstallCode', 'videoInstallMap', 'videoInstallMap')

    // 项目投资性质标准码
    this.initCode('invest_property', 'investPropertyCode', 'investPropertyMap', 'investPropertyMap')
    // 项目状态标准码
    this.initCode('project_state', 'projectStateCode', 'projectStateMap', 'projectStateMap')
    // // 项目类型标准码
    this.initCode('project_type', 'projectTypeCode', 'projectType', 'projectType')
    // 建设性质标准码
    this.initCode('building_property', 'buildingPropertyCode', 'buildingPropertyMap', 'buildingPropertyMap')
    // 工程用途标准码
    this.initCode('project_useage', 'projectUseageCode', 'projectUseageMap', 'projectUseageMap')
    //审批机构标准码
    this.initCode('platApprovalAuthLevel', 'approvalCode', 'approvaleMap', 'approvalMap')
  }
}
</script>

<style lang="scss" scoped>
.zheli-construct-pro-info {
  padding: 20px 0px;
  .sel-style {
    width: 100% !important;
  }
}
.el-date-editor,
.el-input-number {
  width: 100%;
}
</style>
